package com.gzx.plugin.tjzy.xxljob;

import com.gzx.plugin.tjzy.modular.trace.service.GzxTracePlanService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import vip.xiaonuo.common.tenant.TenantContext;
import vip.xiaonuo.common.util.CommonDateUtil;

/**
 * @author xbl
 * @description 跟进计划通知定时任务
 * @date 2025/3/28
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class TracePlanXxlJob {

    private final GzxTracePlanService tracePlanService;

    @XxlJob("noticeCaseJobHandler")
    public void noticeCaseJobHandler() {
        log.info("XxlJob定时任务启动--------------->跟进计划通知{} ", CommonDateUtil.getCurrentTimeStr());
        try {
            TenantContext.disableTenantFilter();
            tracePlanService.noticeCase();
        } catch (Exception e) {
            log.error("跟进计划通知定时任务出现异常", e);
        } finally {
            TenantContext.enableTenantFilter();
            TenantContext.clear();
        }
    }
}
